<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<link href="../../../static/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<link rel="stylesheet" href="../../../static/vui/css/vui.css">

	<script type="text/javascript" src="../../../static/js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../../../static/js/jquery.cookie.min.js"></script>
	<script src="../../../static/layer/layer.js"></script>
	<script type="text/javascript" src="../../../static/laydate/laydate.js"></script>
	<script type="text/javascript" src="../../../static/vui/js/vui.js"></script>
	<script type="text/javascript" src="../../../static/js/common.js"></script>
</head>
<body>

<div class="vui-form-top">
	<div id="formArea">
		<div class="vui-form-row">
			<div class="vui-form-cell">
				<label>调拨日期</label>
				<input type="text" id="date" autocomplete="off" class="input" name="date"/>
			</div>
			<div class="vui-form-cell">
				<button class="button" id="query"><span>查询</span></button>
				<button class="button" id="create"><span>新增</span></button>
			</div>
		</div>
	</div>
</div>
</fieldset>
<div id="table"></div>

<script>
    var editArea = 	[$(document.body).width()+'px', $(document.body).height()+'px'];

    $(function(){
        $('#create').click(function(){
            location.href = 'cost_add.html';
        });

        $('#query').click(function(){
            vui.datagrid("reload","#table",app.serializeForm());
        });

        var currDate = app.time2str(new Date().getTime());
        var firstDate = currDate.substr(0,8)+'01';

        laydate.render({elem: '#date',range: '~',value:firstDate+' ~ '+currDate});

        vui.datagrid({
            id:'table',
            url:app.BASE_API_URL+'costOrder/page',
            columns:[
                {field:'date',title:'调拨日期',width:100,formatter:app.timeFormatter},
                {field:'code',title:'调拨编号',width:180,formatter:function (row) {
                        return '<a dg="1" data-id="'+row.id+'" class="a">DB'+row.code+"</a>";
                    }},
                {field:'stoneName',title:'调整仓库',width:120},
                {field:'price',title:'调整总金额',width:100},
                {field:'userName',title:'制单人',width:100,},
                {field:'status',title:'单据状态',width:100,formatter:function (row) {
                        if( row.status == '1' ){
                            return app.getLable('未调整','warning');
                        }else if( row.status == '2' ){
                            return app.getLable('已调整','success');
                        }else{
                            return '状态异常';
						}
                    }}
            ]
        });
    });

    function loadDataSuccess(){
        $('.a[dg="1"]').click(function(){
            var row = $(this).parent().parent().data();
            location.href = "cost_add.html?code="+row.code+"&id="+row.id+"&status="+row.status;
        });
    }
</script>

</body>
</html>